#pragma once

#include <filesystem>

#include "memdb/impl/IMeta.h"

namespace memdb {
namespace impl {
namespace simple {

class KvTable;

class Meta : public memdb::impl::IMeta {
public :
  Meta(const std::filesystem::path & dbpath);
  ~Meta() override;

public:
	std::error_code open() override;
	std::error_code close() override ;
	bool isOpened() const override;

	std::error_code destroy() override;
  bool exists() const override;

public:
	std::error_code insert(const std::string & key, const std::string & value) override;
	std::error_code remove(const std::string & key) override;
	
	size_t count() const override;

	typedef IMeta::Item Item;
	std::unique_ptr<helper::iter::Iterator<Item>> iterator() const override;

private:
  std::filesystem::path _dbpath;
	std::filesystem::path _dir;
	std::unique_ptr<KvTable> _table;
};

}//namespace simple
}//namespace impl
}//namespace memdb
